import { Program, ProgramOptions } from '../core/Program';
import { OGLRenderingContext } from '../core/Renderer';

const vertex = /* glsl */ `
    precision highp float;
    precision highp int;

    attribute vec3 position;
    attribute vec3 normal;

    uniform mat3 normalMatrix;
    uniform mat4 modelViewMatrix;
    uniform mat4 projectionMatrix;

    varying vec3 vNormal;

    void main() {
        vNormal = normalize(normalMatrix * normal);
        gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
    }
`;

const fragment = /* glsl */ `
    precision highp float;
    precision highp int;

    varying vec3 vNormal;

    void main() {
        gl_FragColor.rgb = normalize(vNormal);
        gl_FragColor.a = 1.0;
    }
`;

export function NormalProgram(gl) {
    return new Program(gl, {
        vertex: vertex,
        fragment: fragment,
        cullFace: null,
    });
}

// export class NormalProgram extends Program {

//     public gltfMaterial;

//     constructor(gl: OGLRenderingContext, options: Partial<ProgramOptions> = {}) {
//         super(gl, options);
//     }
// }
